package com.ruipengkj.service.impl;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.ruipengkj.bean.TOrderRefund;
import com.ruipengkj.commons.base.query.PageModel;
import com.ruipengkj.dao.TOrderRefundDao;
import com.ruipengkj.service.TOrderRefundService;

@Service
public class TOrderRefundServiceImpl implements TOrderRefundService{
	
	@Resource
	private TOrderRefundDao TOrderRefundDao;

	@Override
	public List<TOrderRefund> findService(TOrderRefund entity) throws Exception {
		String hql = "select o from TOrderRefund o";
		StringBuffer whereHQL = new StringBuffer();
		List<Object> param = new ArrayList<Object>();
		if (entity != null) {
			if(whereHQL.length()>4)
				whereHQL.delete(whereHQL.length()-5, whereHQL.length());
		}
		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
		return TOrderRefundDao.findDao(hql, whereHQL.toString(), param, orderby);
	}

	@Override
	public PageModel<TOrderRefund> getScrollService(int firstResult,
			int maxResult, TOrderRefund entity) throws Exception {
		String hql = "select o from TOrderRefund o";
		StringBuffer whereHQL = new StringBuffer();
		List<Object> param = new ArrayList<Object>();
		if (entity != null) {
			if(whereHQL.length()>4)
				whereHQL.delete(whereHQL.length()-5, whereHQL.length());
		}
		whereHQL.append(" o.TOrder.Saler = ? ");
		param.add(entity.getReason());
		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
		return TOrderRefundDao.getScrollDao(hql, whereHQL.toString(), param, firstResult, maxResult, orderby);
	}
	
	@Override
	public TOrderRefund getByIdService(String id) throws Exception {
		return TOrderRefundDao.getByIdDao(id);
	}

	@Override
	public void modifyService(TOrderRefund entity) throws Exception {
		TOrderRefundDao.modifyDao(entity);
	}

	@Override
	public void saveOrUpdateService(TOrderRefund entity) throws Exception {
		TOrderRefundDao.saveOrUpdateDao(entity);
	}

	@Override
	public Serializable saveRetService(TOrderRefund entity) throws Exception {
		return TOrderRefundDao.saveRetDao(entity);
	}

	@Override
	public void saveService(TOrderRefund entity) throws Exception {
		TOrderRefundDao.saveDao(entity);
	}
	
	@Override
	public void deleteService(String id) throws Exception {
		TOrderRefundDao.deleteDao(id);
	}

	public TOrderRefundDao getTOrderRefundDao() {
		return TOrderRefundDao;
	}

	public void setTOrderRefundDao(TOrderRefundDao tOrderRefundDao) {
		TOrderRefundDao = tOrderRefundDao;
	}

	
}
